import type {
	Ref,
} from 'vue';
import type {
	PropOrDescriptor,
	PropOrGetter,
	LazyLoadStatus,
	BeforeProcessor,
} from '../../type';
import type {MySet} from '../../util';

export type TreeLazyLoad<T,R>=BeforeProcessor<TreeNodeMeta<T,R>,T[]>;
export type TreeKey<T>=string|number|T;
export interface UseTreeParam<T,R>{
	objKey:Ref<PropOrGetter<T>>;
	childrenKey:Ref<PropOrDescriptor<T,T[]>>;
	accordion:Ref<boolean>;
	data:Ref<T[]>;
	lazyProp:string;
	expandableProp:string;
	expandProp:string;
	leafProp:string;
	expandedSet:MySet<TreeKey<T>>;
	visibleFilterFn:(meta:TreeNodeMeta<T,R>) => boolean;
	lazyLoadFn:TreeLazyLoad<T,R>;
	injectionLoopFn?:() => injectionFnObj<T,R>;
}
export type injectionFnObj<T,R>={
	initFn?:(meta:TreeNodeMeta<T,R>) => void;
}
export interface RawTreeNodeMeta<T,M>{
	visible:boolean;
	raw:T;
	index:number;
	indent:number;
	parent:TreeNodeMeta<T,M>|undefined;
	hasChildren:boolean;
	validChildren:boolean;
	notLeaf:boolean;
	children?:TreeNodeMeta<T,M>[];
	key:TreeKey<T>;
	keyStr:string|number;
	lazy:undefined|boolean|LazyLoadStatus<boolean>;
	lazyNotLoaded:boolean;
	lazyLoading:boolean;
	expandable:boolean;
	expanded:boolean;
}
export type TreeNodeMeta<T,M=void>=RawTreeNodeMeta<T,M>&M;